/**
 * 设置 cookie 过期时间
 * @returns
 */
const getCookieExpires = () => {
  const d = new Date(); // 当前时间
  d.setTime(d.getTime() + 24 * 60 * 60 * 1000); // 当前时间 + 一天
  return d.toGMTString();
};

// 生成随机ID
function generateRandomID(length) {
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  let result = "";
  for (var i = length; i > 0; --i) {
    result += chars[Math.floor(Math.random() * chars.length)];
  }
  return result;
}

module.exports = {
  getCookieExpires,
  generateRandomID,
};
